package com.wh.usercenter3.exception.handle;

import com.wh.usercenter3.constant.CodeConstant;
import com.wh.usercenter3.exception.BaseException;
import com.wh.usercenter3.response.Result;
import com.wh.usercenter3.response.ResultUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 异常处理类
 */
@RestControllerAdvice
@Slf4j
public class HandleException {

    @ExceptionHandler(BaseException.class)
    public Result baseHandle(BaseException e) {
        log.info("\n 发生异常："+e.getConstant()+" - "+e.getDetail());
        return ResultUtil.err(e.getConstant(),e.getDetail());
    }
}
